package xyz.robinbingo.turing.dubbo.common.protocol;

import org.springframework.util.ObjectUtils;
import xyz.robinbingo.turing.dubbo.common.config.Config;
import xyz.robinbingo.turing.dubbo.common.protocol.dubbo.NettyProtocolServiceImpl;
import xyz.robinbingo.turing.dubbo.common.protocol.http.HttpProtocolServiceImpl;

/**
 * ProtocolServiceFactory
 *
 * @author Robin
 * @date 2021/1/29 下午5:37
 **/
public class ProtocolServiceFactory {

    public static ProtocolService getService() {
        String protocol = Config.PROTOCOL;
        if (ObjectUtils.isEmpty(protocol) || "http".equals(protocol)) {
            return new HttpProtocolServiceImpl();
        } else if ("netty".equals(protocol)) {
            return new NettyProtocolServiceImpl();
        }
        throw new RuntimeException("protocolService null");
    }
}
